$(document).ready(function() {
	init();
	
});

//参数
var query = {
		page: 1,
		rows: 15,
		uname: ""
};

function init(){
	query.page = 1;
	queryBalance(1);
}

function queryBalance(pageNum) {
	if (undefined != pageNum) {
		query.page = pageNum;
	} else {
		query.page = 1;
	}
	createQuery();
}

function createQuery(){
	var path = ctx+"/called/queryCalledStastics";
	commonAjax(path,query,function(data){
		if(data.success){
			var pageStr = new Array; 
			$.each(data.rows,function(index,row){
				pageStr.push('<tr>');
				pageStr.push('<td>'+(index+1)+'</td>');
				pageStr.push('<td><a href="#" >'+row.usDate+'</a></td>');
				pageStr.push('<td><a href="#" >'+row.usTime+'</a></td>');
				pageStr.push('<td><a href="#" >'+row.usMoney+'</a></td>');
				pageStr.push(' </tr>');
			});
			$("#pagelist").html(pageStr.join(""));
			
			var page_options = {
					id:"content_page",
					pageCount:data.pageCount,
					current:data.pageNumber,
					callback:"queryBalance"
			}
			pages(page_options);
		}else{
			showMsg(data.msg);
		}
	});
}


function showMsg(msg){
	$("#alert-msg").html(msg);
	$("#my-msg").modal();
}

function delUser(id){
	var delPath = ctx+'/user/del';
	var depParam = {
			id:id
	}
	showConfirm("确认删除该条记录吗？",function(){
		commonAjax(delPath,depParam,function(data){
			if(data.success){
				createQuery();
			}
			showMsg(data.msg);
		});
	});
}

